#!/bin/bash
[  -f "$HOME/myconfig" ] && . $HOME/myconfig

dbName=maxkey
host(){
    cat - >> /etc/hosts << EOF
127.0.0.1  sso.maxkey.top
127.0.0.1  tokenbased.demo.maxkey.top
127.0.0.1  cas.demo.maxkey.top
127.0.0.1  oauth.demo.maxkey.top
EOF

}

sy(){

  rsync -av --exclude-from=exclude_files . root@47.94.44.45:/data/MaxKey
}
cb(){
  (cd maxkey-web-manage;gradle clean jibDockerBuild --info)
  (cd maxkey-web-maxkey;gradle clean jibDockerBuild --info)
}
sf(){
  rsync -av deploy/sys/e_*.conf /data/fogpod/data/nginx/conf/vhost
}
st(){

  (cd deploy;docker-compose stop)
}
r(){

  (cd deploy;docker-compose restart)
}
s1(){

  (cd deploy;docker-compose up --force-recreate)
}
lf(){
  (cd deploy;docker-compose logs -f "$@")
}
l(){
  (cd deploy;docker-compose logs "$@")
}
ps(){

  (cd deploy;docker-compose ps)
}
fa(){
  (cd deploy;docker-compose up --force-recreate -d fogpodid-mgmt fogpodid)
}
fs(){
  (cd deploy;docker-compose up --force-recreate -d "$@")
}
s(){
  (cd deploy;docker-compose up -d)
}
b(){
  (cd maxkey-web-manage;gradle  jibDockerBuild --info)
  (cd maxkey-web-maxkey;gradle  jibDockerBuild --info)
}
import_sql(){
    local dbName=$1

    mysql -uroot -p"$mysql_pwd" -e "drop database $dbName;create DATABASE $dbName CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
}
init(){
    import_sql $dbName
    mysql -uroot -p"$mysql_pwd"  -D $dbName < ./sql/maxkey_v2.4.0.GA.sql
}

"$@"